package forum.entities;

import java.math.BigInteger;

public class Topic extends Entity {

    private String topicName;
    private BigInteger parentCategoryId;
    private BigInteger authorId;

    public Topic(BigInteger id) {
        super(id);
    }

    public Topic(BigInteger id, String topicName, BigInteger parentCategoryId, BigInteger authorId) {
        super(id);
        this.topicName = topicName;
        this.parentCategoryId = parentCategoryId;
        this.authorId = authorId;
    }

    public String getTopicName() {
        return topicName;
    }

    public void setTopicName(String topicName) {
        this.topicName = topicName;
    }

    public BigInteger getParentCategoryId() {
        return parentCategoryId;
    }

    public void setParentCategoryId(BigInteger parentCategoryId) {
        this.parentCategoryId = parentCategoryId;
    }

    public BigInteger getAuthorId() {
        return authorId;
    }

    public void setAuthorId(BigInteger authorId) {
        this.authorId = authorId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (! (o instanceof Topic)) return false;
        if (! super.equals(o)) return false;

        Topic topic = (Topic) o;

        if (authorId != null ? ! authorId.equals(topic.authorId) : topic.authorId != null) return false;
        if (parentCategoryId != null ? ! parentCategoryId.equals(topic.parentCategoryId) : topic.parentCategoryId != null)
            return false;
        if (topicName != null ? ! topicName.equals(topic.topicName) : topic.topicName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (topicName != null ? topicName.hashCode() : 0);
        result = 31 * result + (parentCategoryId != null ? parentCategoryId.hashCode() : 0);
        result = 31 * result + (authorId != null ? authorId.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Topic{" +
                "topicName='" + topicName + '\'' +
                ", parentCategoryId=" + parentCategoryId +
                ", authorId=" + authorId +
                "} " + super.toString();
    }
}
